<?php
/**
 * Authenticate logic for admin area
 *
 * @author Mario Schillermann <info@rockit-flash.com>
 * @encoding UTF-8 äöüßÖÄÜ
 * @copyright © 2011 Mario Schillermann (info@rockit-flash.com)
 * @license GNU GPL v2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
 * @package Page
 * @subpackage Index
 * @link $HeadURL$
 * @version SVN: $Id$
 * @phpVersion >=5
 * @todo App überprüfung gegen Missbrauch einbauen Zeile 40
 */

class Rockitbos_WebController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }
    /**
     * Login logic
     *
     * @return void
     */
    public function indexAction()
    {
        $auth = Zend_Auth::getInstance();

        if ($this->getRequest()->set == 'logout') {
            // log out
            $auth->clearIdentity();
            // redirect to login form
            $this->_redirect('/rockitbos');
        } else if ($auth->hasIdentity()) {

            $app = $this->getRequest()->app;
            $tab = $this->getRequest()->tab;

            if (!empty($app)) {

                $layout = Zend_Layout::getMvcInstance();
                // Set a layout script path for app nav
                $layout->setLayoutPath('application/modules/rockitbos/views/scripts');
                $layout->setLayout('app');

                if(empty($tab)) {
                    $tab = 'app';
                }
                $this->_forward('index', $tab, $app);
            } else {
                $this->_forward('index', 'dashboard');
            }
        } else {
            // show login form
            $this->_forward('login', 'login');
        }
    }
}